|
|
|
|
|
|
|
Here are some examples of better procedure names: |
|
|
|
|
|
|
|
|
The difference is the noun, or object, is placed first. There are fewer ways to describe an object than there are for a verb to describe what will be done. For example, the verb display can be expressed a couple other ways, such as show,draw, or even print. However, a form is always a form, theres no other descriptor for it. |
|
|
|
|
|
|
|
|
In object-oriented languages and even in VB, the object name is placed first and then the method or action you want to perform on that object. Objects are always nouns, and actions are verbs. You should follow this coding style when creating names for your procedures. |
|
|
|
|
|
|
|
|
An additional benefit of this coding style is that when you use a cross-referencing tool or are looking in the Proc combo box, youll see all functions that operate on a particular object grouped in one place. |
|
|
|
|
|
|
|
|
Labels in a procedure should only be used for error handling. Otherwise, too many programmers would be tempted to use the GoTo statement. A GoTo statement can lead to many problems. Name your labels with the name of the procedure followed by the suffix _EH. Heres an example: |
|
|
|
 |
|
|
|
|
Private Sub cmdSave_Click()
On Error GoTo cmdSav_Click_EH
...
...
cmdSave_Click_EH:
' Error handling here
End Sub |
|
|
|
|
|